<?php
$loader->requireOnce('lib/PHPExcel/PHPExcel.php');
$loader->requireOnce('lib/PHPExcel/PHPExcel/IOFactory.php');
class ExportExcelHelper{
	public static function bindRow(&$objSheet, $data, $idxColumn='A', $idxRow='1'){
		$currentColumn	=	$idxColumn;	
		foreach($data as $item){
			$objSheet->setCellValue($currentColumn.$idxRow, $item);
			$currentColumn	=	chr(ord($currentColumn)+1);
		}
		// Return the last column bound data
		return chr(ord($currentColumn)-1);
	}
	
	public static function bindColumn(&$objSheet, $data, $idxColumn='A', $idxRow=1){
		$currentRow	=	$idxRow;	
		foreach($data as $item){
			$objSheet->setCellValue($idxColumn.$currentRow, $item);
			$currentRow++;
		}
		
		// Return the last row bound data
		return $currentRow-1;
	}
	
	public static function setColumnWidths(&$objSheet, $data, $idxColumn='A'){
		$currentColumn	=	$idxColumn;	
		foreach($data as $item){
			$objSheet->getColumnDimension($currentColumn)->setWidth($item);
			$currentColumn	=	chr(ord($currentColumn)+1);
		}
		// Return the last column bound data
		return chr(ord($currentColumn)-1);
	}
	
	public static function setRowHeights(&$objSheet, $data, $idxRow=1){
		$currentRow	=	$idxRow;
		foreach($data as $item){
			$objSheet->getRowDimension($currentRow)->setRowHeight($item);
			$currentRow++;
		}
		// Return the last row bound data
		return $currentRow-1;
	}
}
?>